package com.euc.springbootframework.audit;

import com.euc.springbootframework.entity.User;
import org.springframework.context.annotation.Bean;
import org.springframework.data.domain.AuditorAware;
import org.springframework.stereotype.Component;

import java.util.Optional;

@Component("SpringAuditorAware")
public class SpringAuditorAware implements AuditorAware<User> {

    private User auditor;

    /**
     * @param auditor the auditor to set
     */
    public void setAuditor(User auditor) {
        this.auditor = auditor;
    }

    @Override
    public Optional<User> getCurrentAuditor() {
        User user = new User();
        user.setUsername("geralt");
        return Optional.ofNullable(user);
    }
}
